package com.atguigu.aiproject.service.impl;

import com.atguigu.aiproject.mapper.ChatSessionMapper;
import com.atguigu.aiproject.entity.ChatSession;
import com.atguigu.aiproject.service.ChatSessionService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class ChatSessionServiceImpl extends ServiceImpl<ChatSessionMapper, ChatSession>
        implements ChatSessionService {

    /**
     * 根据用户pair，查询会话
     */
    @Override
    public ChatSession getByUserPair(Integer user1Id, Integer user2Id) {
        QueryWrapper<ChatSession> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user1_id", user1Id).eq("user2_id", user2Id);
        return this.getOne(queryWrapper);
    }
}
